package pack3;

public class test7 {
    public static void main(String[] args) {
        String s = "AbC123sdfg7FCM987D0ddFFPAZvvvFFggg43";
        s = s.toLowerCase();


        String subStr = s.substring(5, 11);
        System.out.println("第5个到第10个字符: " + subStr);


        int[] charCount = new int[128];
        for (int i = 0; i < s.length(); i++) {
            charCount[s.charAt(i)]++;
        }


        int maxCount = 0;
        int minCount = s.length();
        char maxChar = '\0';
        char minChar = '\0';
        for (int i = 0; i < charCount.length; i++) {
            if (charCount[i] > 0) {
                if (charCount[i] > maxCount) {
                    maxCount = charCount[i];
                    maxChar = (char)i;
                }
                if (charCount[i] < minCount) {
                    minCount = charCount[i];
                    minChar = (char)i;
                }
            }
        }
        System.out.println("出现最多的字符是: " + maxChar + "，个数是: " + maxCount);
        System.out.println("出现最少的字符是: " + minChar + "，个数是: " + minCount);


        String replacedStr = s.replace(Character.toString(maxChar), "#");
        System.out.println("替换后的字符串: " + replacedStr);

        StringBuilder reversed = new StringBuilder(replacedStr);
        System.out.println("逆序后的字符串: " + reversed.reverse().toString());
    }
}